Skip to content

CMake: Add picosystem_asset for packing .16bpp into .o#29

Draft
Gadgetoid wants to merge 1 commit intomainfrom
feature/asset-compiler
Draft

CMake: Add picosystem_asset for packing .16bpp into .o#29
Gadgetoid wants to merge 1 commit intomainfrom
feature/asset-compiler

Conversation

@Gadgetoid
Copy link
Copy Markdown
Member

@Gadgetoid Gadgetoid commented Oct 20, 2021

Use the linker to convert an asset into an .o file and include it in project sources.

TODO: Fix const resources/.rodata assets

Example

Add the following to your CMakeLists.txt:

# Link the platformer spritesheet
picosystem_asset(${PROJECT_NAME} ../assets/s4m_ur4i-platformer.16bpp)

And to your main .cpp:

extern char _binary_s4m_ur4i_platformer_16bpp_start[];
buffer_t *platformer = buffer(128, 128, (void *)_binary_s4m_ur4i_platformer_16bpp_start);

void init() {
    spritesheet(platformer);
}

⚠️ At the moment I can't seem to get this working with constant data, so it will eat 32K of RAM.

Use the linker to convert an asset into an .o file and include it in project sources.

TODO: Fix const resources/.rodata assets
@Fordi
Copy link
Copy Markdown
Contributor

Fordi commented Oct 20, 2021

Awesome! I'm going to try this in my scratch project.

[Edit: works as advertised, but my script (here) builds directly from an image, rather than a .16bpp binary, which makes the workflow a bit easier (though, I suppose I could run convert-image.py {pngfile} before make just as easily as ../tools/build-spritesheet.js {pngfile}).]

@Gadgetoid
Copy link
Copy Markdown
Member Author

Gadgetoid commented Oct 20, 2021

Our 32blit SDK has - effectively - a manifest of files which it slurps up and runs through the 32blit tool for packing/conversion. All very handy dandy and unlike this basic nonsense 😆

eg: https://github.com/32blit/rocks-and-diamonds/blob/main/assets.yml

BUT... where's the fun in that? 32blit users got to build their own empire... PicoSystem users can have some fun too!

(P.S. it's cool that you're putting together tools to serve your purposes, it's all part of the fun!)

@Fordi
Copy link
Copy Markdown
Contributor

Fordi commented Oct 20, 2021

...ooo, that's pretty. I wonder how that works.

@og-syn
Copy link
Copy Markdown

og-syn commented Oct 30, 2021

@Gadgetoid are you looking for input/feedback on this? I have a half baked patch (minus the cmae stuff, I'm generating .h files manually and including them) that does more or less this, but defines a robuffer_t and templatizes some functions to they can use it. That way all data ends up in ROM.

@Gadgetoid
Copy link
Copy Markdown
Member Author

That way all data ends up in ROM.

I was waiting until I had a moment to figure out how to do this. If you want to fork this branch for the CMake stuff and submit your own take on this PR I'd be happy to review it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants